home *** CD-ROM | disk | FTP | other *** search
-
-
-
- PPPPTTTTYYYY((((7777MMMM)))) PPPPTTTTYYYY((((7777MMMM))))
-
-
-
- NNNNAAAAMMMMEEEE
- pty, pts - pseudo terminal driver
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- The _p_t_y driver provides a device-pair termed a _p_s_e_u_d_o _t_e_r_m_i_n_a_l. A pseudo
- terminal is a pair of character devices, a _m_a_s_t_e_r device and a _s_l_a_v_e
- device. The slave device provides processes an interface identical to
- that described in _t_e_r_m_i_o(7). However, whereas all other devices which
- provide the interface described in _t_e_r_m_i_o(7) have a hardware device of
- some sort behind them, the slave device has, instead, another process
- manipulating it through the master half of the pseudo terminal. That is,
- anything written on the master device is given to the slave device as
- input and anything written on the slave device is presented as input on
- the master device.
-
- The following _i_o_c_t_l calls apply only to pseudo terminals:
-
- TIOCPKT
- Enable/disable _p_a_c_k_e_t mode. Packet mode is enabled by specifying
- (by reference) a nonzero parameter and disabled by specifying (by
- reference) a zero parameter. When applied to the master side of a
- pseudo terminal, each subsequent _r_e_a_d from the terminal will return
- data written on the slave part of the pseudo terminal preceded by a
- zero byte (symbolically defined as TIOCPKT_DATA), or a single byte
- reflecting control status information. In the latter case, the byte
- is an inclusive-or of zero or more of the bits:
-
- TIOCPKT_FLUSHREAD
- whenever the read queue for the terminal is flushed.
-
- TIOCPKT_FLUSHWRITE
- whenever the write queue for the terminal is flushed.
-
- TIOCPKT_STOP
- whenever output to the terminal is stopped a la ^S.
-
- TIOCPKT_START
- whenever output to the terminal is restarted.
-
- TIOCPKT_DOSTOP
- whenever _t__s_t_o_p_c is ^S and _t__s_t_a_r_t_c is ^Q.
-
- TIOCPKT_NOSTOP
- whenever the start and stop characters are not ^S/^Q.
-
- This mode is used by _r_l_o_g_i_n(1C) and _r_l_o_g_i_n_d(1M) to implement a
- remote-echoed, locally ^S/^Q flow-controlled remote login with
- proper back-flushing of output; it can be used by other similar
- programs.
-
-
-
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- PPPPTTTTYYYY((((7777MMMM)))) PPPPTTTTYYYY((((7777MMMM))))
-
-
-
- AAAALLLLLLLLOOOOCCCCAAAATTTTIIIIOOOONNNN
- The code sequence shown below demonstrates how to allocate pseudo
- terminals. Pseudo terminals, like all files, must have the correct file
- permissions to be accessible. The ____ggggeeeettttppppttttyyyy(3) library function takes care
- of this problem.
-
- #include <fcntl.h>
- #include <unistd.h>
-
- /*
- * Find a pseudo tty to use and open both sides.
- * filedes[0] receives the master file descriptor while filedes[1]
- * receives the slave. The master is opened with O_NDELAY as commonly
- * needed in daemons such as rlogind and telnetd.
- */
- int /* -1 on failure */
- findPseudoTTY(int *filedes)
- {
- char *line;
-
- line = _getpty(&filedes[0], O_RDWR|O_NDELAY, 0600, 0);
- if (0 == line)
- return -1;
- if (0 > (filedes[1] = open(line, O_RDWR))) {
- (void)close(filedes[0]);
- return -1;
- }
- return 0;
- }
-
- FFFFIIIILLLLEEEESSSS
- /dev/ptc - master pseudo terminal
- /dev/tty[qrstuvwxyz][0-99] - slave pseudo terminals
- /dev/pts - equivalent to /dev/ttyq[0-9]
-
- SSSSEEEEEEEE AAAALLLLSSSSOOOO
- getpty(3)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-